import Vue from 'vue'
import {validatenull} from '@/util/validate'

const tabs={
  state:{
    tabList:[],
    offenList:[],
    currentSide:''
  },
  mutations:{
    SET_TAB_LIST(state,data){
      state.tabList = data
    },
    SET_OFFEN_LIST(state,data){
      state.offenList = data
    },
    SET_MENUSET_LIST(state,data){
      if (validatenull(data)) return;
      //合并动态路由去重
      let menuAll = data;
      menuAll = menuAll.concat(data);
      let newMenu = [];
      for (let item1 of menuAll) {
        let flag = true;
        for (let item2 of newMenu) {
          if (item1.name === item2.name || item1.path === item2.path) {
            flag = false;
          }
        }
        if (flag) {
          newMenu.push(item1);
        }
      }
      // newMenu.unshift({
      //   name:'常用',
      //   id:'#',
      //   source:'el-icon-s-grid',
      //   children:state.offenList
      // })
      // state.menuSetListAll = newMenu
    },
    SET_CURRENT_SIDE(state,data){
      state.currentSide = data
    },
  },
}
export default tabs
